//
//  Images_two_averageTableViewCell.m
//  ChunLaiZhuangClient
//
//  Created by zouzhisheng on 16/4/9.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "Images_two_averageTableViewCell.h"

@implementation Images_two_averageTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *identifier = @"Images_two_averageTableViewCell";
    // 1.缓存中取
    Images_two_averageTableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    // 2.创建
    if (cell == nil) {
        cell = [[Images_two_averageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView *upLine=[[UIView alloc] initWithFrame:CGRectMake(0, 4.5, SCREEN_WIDTH, 0.5)];
        upLine.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        _leftImageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 5, SCREEN_WIDTH/2-1, 200)];
        _leftImageView.contentMode=UIViewContentModeScaleAspectFit;
        _leftImageView.clipsToBounds=YES;
        _leftImageView.tag=0;
        
        _rightImageView=[[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-1, 5, SCREEN_WIDTH/2-1, 200)];
        _rightImageView.contentMode=UIViewContentModeScaleAspectFit;
        _rightImageView.clipsToBounds=YES;
        _rightImageView.tag=1;
        
        UIView *downLine=[[UIView alloc] initWithFrame:CGRectMake(0,205, SCREEN_WIDTH, 0.5)];
        downLine.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        
        UIView *middleLine=[[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2,4.5,0.5, 200)];
        middleLine.backgroundColor=[UIColor colorWithHexString:@"cacaca"];
        [self addSubview:upLine];
        [self addSubview:_leftImageView];
        [self addSubview:_rightImageView];
        [self addSubview:middleLine];
        [self addSubview:downLine];
        
        
        
        _leftImageView.userInteractionEnabled=YES;
        _rightImageView.userInteractionEnabled=YES;
        UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
         UITapGestureRecognizer *tap2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [_leftImageView addGestureRecognizer:tap1];
        [_rightImageView addGestureRecognizer:tap2];
        
    }
    return self;
}

-(void)setImages_two_averageModel:(Images_two_averageModel *)images_two_averageModel{
    _images_two_averageModel=images_two_averageModel;
    Images_averageModel *model=_images_two_averageModel.module_data;
    [_leftImageView sd_setImageWithURL:[NSURL URLWithString:((ImagesDetailModel *)model.images[0]).image] placeholderImage:nil];
    [_rightImageView sd_setImageWithURL:[NSURL URLWithString:((ImagesDetailModel *)model.images[1]).image] placeholderImage:nil];
    
    
    
}
-(void)tapAction:(UITapGestureRecognizer*)tap{
    Images_averageModel *averageModel=_images_two_averageModel.module_data;
    ImagesDetailModel *detailModel=averageModel.images[tap.view.tag];
     [TransferManager transferToSomeViewType:detailModel.link_type linkID:detailModel.link_id  linkName:detailModel.link_name fromView:self];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
